﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using interfaceOperadores;



namespace Calculadora
{
    public partial class Calculadora : Form
    {
        public Calculadora()
        {
            InitializeComponent();
            this.actualizarComboBox();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void igual_Click(object sender, EventArgs e)
        {
            try
            {
                iOperadores operador = (iOperadores)comboBox.SelectedItem;
                label.Text = operador.operar(float.Parse(cajaUno.Text), float.Parse(cajaDos.Text)) + "";
            }
            catch (System.FormatException ex)
            {
                label.Text = "Ingrese una cadena de números correcta";
            }
            catch (NullReferenceException ex)
            {
                label.Text = "Seleccione operador"; 
            }
            

        }

        private void refresh_Click(object sender, EventArgs e)
        {
            this.actualizarComboBox();
        }

    }
}
